import * as _ from "lodash"
import { camelCase } from "../case"
import httpClient from "../httpclient"

export enum CurrencyCode {
  CNY = "cny"
}

export class Balance {
  public currencyCode: CurrencyCode
  public pendingAmount: number = 0
  public availableAmount: number = 0
  public freezeAmount: number = 0
}


export class BalanceServiceV1 {

  public static getBalance(accountId: string, currencyCode: string): Promise<Balance> {
    return httpClient.get(`/v1/accounts/${accountId}/balances/${currencyCode}`)
      .then(({ data }) => data)
      .then(camelCase)
      .then(data => _.assign(new Balance(), data))
  }

}
